﻿using CommunicationProtocol.dto.command.client;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using monoClient.utils;
using static monoClient.utils.Constant;
using CommunicationProtocol.dto;
using System;

namespace monoClient.renderer
{
    public class OtherPlayerPlantingRenderer:CommandExecutor
    {
        public OtherPlayerPlantingCommand otherPlayerPlantingCommand { get; }

        Rectangle location;

        private readonly Texture2D texture2D;

        public OtherPlayerPlantingRenderer(OtherPlayerPlantingCommand otherPlayerPlantingCommand, StaticPlant targetPlant)
        {
            this.otherPlayerPlantingCommand = otherPlayerPlantingCommand;

            location= new Rectangle(otherPlayerPlantingCommand.xPixel,
                                      otherPlayerPlantingCommand.yPixel,
                                      defaultBuyablePlantWidth,
                                      defaultBuyablePlantHeight
                                      );

            texture2D = ImageUtils.loadImagesByObjectType(
                targetPlant.ObjectType
                )[0];

        }

       

        public void Update(GameTime gameTime, MouseState mouseState, MouseState oldMouseState)
        {
            
        }

        public void Draw(GameTime gameTime, SpriteBatch _spriteBatch)
        {
            _spriteBatch.Draw(texture2D, location, Color.White);
        }

        internal void updateLocation(int xPixel, int yPixel)
        {
            location.Location = new Point(xPixel, yPixel);
        }
    }
}